home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / nos042_s / overscan.h < prev    next >
Text File  |  1992-12-20  |  7KB  |  216 lines

  1. /*************************************************************
  2.  *
  3.  * OVERSCAN.H         (c)1990  K.Isakovic   Berlin, 12.03.90
  4.  *
  5.  *************************************************************
  6.  *    HEADER-File for the OverScan-Xbios-Extensions
  7.  *
  8.  * The special OverScan Xbios functions have no effect under
  9.  * `normal conditions'. They do not produce any bombs or
  10.  * error messages. They are just ignored.
  11.  *
  12.  * The function numbers changed since the last OverScan versions,
  13.  * because TT-TOS needs the numbers 84-90. The old numbers are
  14.  * still processed.
  15.  *
  16.  * for TurboC 1.1
  17.  *
  18.  * updated for LATTICE C V5.5 by David Nash
  19.  * SCREEN -> OSCAN_SCREEN
  20.  * OVERPATCH -> OSCAN_PATCH
  21.  */ 
  22. /*#include <tos.h> */
  23.  
  24. typedef struct 
  25. {
  26.  short    width;            /* width in pels                   */
  27.  short    height;           /* height in pels                  */
  28.  short    bytes_per_line;   /* bytes per screen line           */
  29.  long        length_of_screen; /* screen length in bytes          */
  30.  long        physbase_offset;  /* screen start offset != Physbase */
  31.  long        logbase_offset;   /* screen start offset != Logbase  */
  32. } OSCAN_SCREEN;
  33.  
  34. typedef struct
  35. {
  36.  short  low_w  ,mid_w  ,high_w;   /* width in pels                 */
  37.  short  low_h  ,mid_h  ,high_h;   /* height in pels                */
  38.  long low_off,mid_off,high_off; /* screen offset != Logbase      */
  39.  long mono_add,color_add;       /* additional memory requirement */
  40.  char clear_scan;               /* scan code of clear function   */
  41.  char clear_shift;              /* shift code of clear function  */
  42.  char setup_shift;              /* shift code for setup (mask)   */
  43.  char invert_shift;             /* shift code to invert mode     */
  44.  char abort_shift;              /* shift code to cancel          */
  45. } OSCAN_PATCH;
  46.  
  47. int Oscanis(void)
  48. {
  49.   return (int)xbios(4200) ;
  50. }
  51. /*
  52.  * Returns either 4200 or version number. Version 1.8 (the first
  53.  * supporting Xbios) returns $0108 (HEX!). The present version 3.0
  54.  * yields $300 etc. A return value of 4200 corresponds to version
  55.  * 10.68 and would therefore never appear.
  56.  * 
  57.  */
  58.  
  59. OSCAN_SCREEN *Oscantab(int Res)
  60. {
  61.  return (OSCAN_SCREEN *)xbios(4201,Res) ;
  62. }
  63. /*
  64.  * Returns a pointer to the data structure OSCAN_SCREEN. Res tells, for
  65.  * which of the resolutions the pointer is required. For each
  66.  * resolution a different pointer is returned.
  67.  * The following values are valid:
  68.  *    Res  0 -> Low
  69.  *    Res  1 -> Mid
  70.  *    Res  2 -> High
  71.  *    Res -1 -> Current resolution. The switch position is 
  72.  *              considered.
  73.  * The data structure is updated with every call of Oscantab().
  74.  */
  75.  
  76. int Oscanphy(int Mode)
  77. {
  78.  return (int)xbios(4202,Mode);
  79. }
  80. /*    
  81.  * This function sets the Physbase emulator's mode. If the emulator
  82.  * is turned on, the value of Logbase is returned.
  83.  *
  84.  *    Mode  0 -> PhysbaseEmulator off
  85.  *    Mode  1 -> PhysbaseEmulator on  (default)
  86.  *    Mode -1 -> get state
  87.  *
  88.  * IMPORTANT!
  89.  *------------
  90.  *   You must turn on the Physbase emulator before programme 
  91.  *   termination!
  92.  */
  93.  
  94. int Oscanscr(int Mode)
  95. {
  96.   return (int)xbios(4203,Mode);
  97. }
  98. /*    
  99.  * This function enables or disables the `Setscreen' call.
  100.  * Normally, relocation of the screen or changing the resolution
  101.  * is not allowed with OverScan.
  102.  *
  103.  *    Mode  0 -> enable Setscreen
  104.  *    Mode  1 -> DISABLE Setscreen (default)
  105.  *    Mode -1 -> get state
  106.  * The current state is returned.
  107.  *
  108.  * If you want to change the screen memory address, you must not
  109.  * destroy the offset between Logbase and Physbase.
  110.  *
  111.  * IMPORTANT!
  112.  *------------
  113.  *   You must disable the Setscreen call before programme termination!
  114.  */
  115.  
  116. int Oscanvb(int Mode)
  117. {
  118.   return (int)xbios(4204,Mode);
  119. }
  120. /*
  121.  * This function may disable the VB Randtest routine and the test
  122.  * for Shift/Shift/Clear in the IKBD interrupt.
  123.  * These tests cost 1-2% cpu time, what might be too much for time
  124.  * critical MIDI routines or animations.
  125.  *
  126.  *    Mode  0 -> disable tests
  127.  *    Mode  1 -> enable tests  (default)
  128.  *    Mode -1 -> get state
  129.  * The current state is returned.
  130.  *
  131.  * IMPORTANT!
  132.  *------------
  133.  *  You have to enable the tests before programme termination.
  134.  */
  135.  
  136. OSCAN_PATCH *Oscanpatch(void)
  137. {
  138.   return (OSCAN_PATCH *)xbios(4205);
  139. }
  140. /*
  141.  * Returns a pointer to the OverScan patch area.
  142.  */
  143.  
  144. int Oscanswitch(int Mode)
  145. {
  146.   return (int)xbios(4206,Mode);
  147. }
  148. /*
  149.  * This is the most powerful function OverScan provides. It
  150.  * switches the current mode. Not only the hardware is switched
  151.  * but all GEM variables are updated and the screen contents are
  152.  * copied.
  153.  *
  154.  *    Mode  0 -> normal mode
  155.  *    Mode  1 -> OverScan
  156.  *    Mode -1 -> get state
  157.  * The current state is returned.
  158.  */
  159.  
  160.  
  161. /*************************************************************
  162.  *  Utility function to create a second screen page
  163.  *  Works without OverScan also
  164.  */
  165. int OverscanScreen(long *Block,long *NewLog,long *NewPhy,int Res)
  166. {
  167. /*  Block     pointer to the memory area returned by Malloc
  168.  *  NewLog    pointer to Logbase value of the new screen page
  169.  *  NewPhy    pointer to Physbase value of the new screen page
  170.  *  Rez       required resolution for the new screen page
  171.  *
  172.  *  If no memory is available for the second screen page, Block
  173.  *  is negative and the function returns 0. Otherwise 1 is returned.
  174.  */
  175.   if ((int)Oscanis()!= 4200)             /* test OverScan version */
  176.     {
  177.     OSCAN_SCREEN *Over;
  178.  
  179.     Over   = Oscantab(Res);                         /* get values */
  180.     *Block = (long)Malloc(Over->length_of_screen);  /* memory     */
  181.     if (*Block > 0)
  182.       {
  183.       *NewLog = ((*Block+256L)&0xffff00L) + Over->logbase_offset;
  184.       *NewPhy = ((*Block+256L)&0xffff00L) + Over->physbase_offset;
  185.       return 1;
  186.       }
  187.     }
  188.   else
  189.     {
  190.     *Block  = (long)Malloc(32256L);               /* wo/ OverScan */
  191.     if (*Block>0)
  192.       {
  193.       *NewLog = (*Block+256L)&0xffff00L;
  194.       *NewPhy = *NewLog;
  195.       return 1;
  196.       }
  197.     }
  198.   return 0;
  199. }
  200.  
  201. /*************************************************************
  202.  * Utility function to get Logbase/Physbase values
  203.  * Works without OverScan also
  204.  */
  205. void OscanLogPhy(long *CurLog,long *CurPhy)
  206. {
  207. int Emulator;
  208.  
  209.  Emulator = Oscanphy(-1);       /* save old state               */
  210.  Oscanphy(0);                   /* Physbase emulator off        */
  211.  *CurLog = (long)Logbase();
  212.  *CurPhy = (long)Physbase();
  213.  Oscanphy(Emulator);            /* restore old state            */
  214. }
  215.  
  216.